<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>11</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/push.js/1.0.9/push.js"></script>
</head>

<body>
    <div>令牌: {$jwt}</div>
    <div>
        <?php dump($info) ?>
    </div>
    <input type="text">
    <script>
        //禁用右键（防止右键查看源代码） 
    // window.oncontextmenu = function () { return false; }
    //禁止任何键盘敲击事件（防止F12和shift+ctrl+i调起开发者工具） 
    window.onkeydown = function () {
       if (window.event && window.event.keyCode == 123) {
            alert("F12被禁用");
            event.keyCode = 0;
            event.returnValue = false;
        }
    } 
    //禁止选择文本
        document.onselectstart = new Function("event.returnValue=false");  


        Push.create("Hello world!", {
            //通知的正文
            body: "How's it hangin'?",
            icon: '/icon.png',
            //自动关闭时间
            timeout: 4000,
            onClick: function () {
                window.focus();
                this.close();
            }
        });
      var a=  Push.Permission.has();
      console.log(a);
      Push.Permission.request(function(){
                console.log('1');
      }, function(){
                console.log(2);
      });
    </script>
    <div>
        <h2>apk详情</h2>
        <input type="file" name="file" id="file" onchange="fileSelect()">
        <div>
            <img src="" id="ico">
            版本<b id="ve"></b>
            包名<b id="pake"></b>
            安装后的名字<b id="name"></b>
        </div>
        <br><br>
    </div>
    <script src="__STATIC__/admin/app-info-parse.js"></script>
    <script>
        function fileSelect() {
            const files = document.getElementById('file').files
            const parser = new AppInfoParser(files[0])
            parser.parse().then(result => {
                var appInfo = result.application || {};
                var name = appInfo.label ? (Array.isArray(appInfo.label) ? appInfo.label[0] : appInfo.label) :
                    '';
                console.log('app info ----> ', result)
                $('#ico').attr('src', result.icon);
                $('#ve').text(result.versionName);
                $('#pake').text(result.package);
                $('#name').text(name);
            }).catch(err => {
                console.log('err ----> ', err)
            })
        }
    </script>
    <script>
        ws = new WebSocket("ws://leqq00.51vip.biz:80");
        var msg;
        ws.onopen = function () {
            //定时发送心跳
            setInterval(function () {
                xintiao();
            }, 1000)
        };
        ws.onmessage = function (e) {
            console.log(e.data);
            msg = e.data;
            var arr = JSON.parse(e.data);
            if (arr.type == 'client_id') {
                register(arr.client_id);
            }

        };

        function register(cid) {
            var obj = {
                'type': 'register',
                'client_id': cid,
                'mac': 'a0:45:78:96:sb',
                'who': 'test'
            };
            return ws.send(JSON.stringify(obj));
        }

        //心跳检测
        function xintiao() {
            ws.send('{"type":"ping"}');
        }
    </script>
</body>

</html>